﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace WebApi.Core.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TestSerilogController : ControllerBase
    {
        private readonly ILogger<TestSerilogController> _logger;

        public TestSerilogController(ILogger<TestSerilogController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 测试日至
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult LogTest()
        {
            //_logger.LogInformation("info 日志");
            //_logger.LogDebug("debug 日志");
            //_logger.LogError(new System.IO.IOException(),"io 错误");

            //注意Ip要与appsetting.json里的设置一致,区分大小写
            _logger.LogInformation("ip:{Ip},username{UserName},userid:{UserId}","127.0.0.1","admin","13");


            return Ok();
        }


    }
}